import { createWebHashHistory,createRouter } from "vue-router";

import Layout from "../pages/Main.vue";
import Home from "../pages/home/index.vue";
import Order from "../pages/order/index.vue";
import User from "../pages/user/index.vue";
import Setin from "../pages/setin/index.vue";
import Login from "../pages/login/index.vue";
import createOrder from "../pages/createOrder/index.vue";
import detail from "../pages/detail/index.vue";

const routes=[
    {
        path:"/",
        component:Layout,
        // name:'main',
        // redirect:to=>{
        //     const localData=localStorage.getItem('pz_v3pz');
        //     if(localData){
        //         const child=JSON.parse(localData).menu.routerList[0].children;
        //         if(child){
        //             return child[0].meta.path;
        //         }else{
        //             return JSON.parse(localData).menu.routerList[0].menu.path;
        //         }
        //     }else{
        //         return '/login';
        //     }
        // },
        redirect:'/home',
        children:[
            {
                path:"/home",
                meta:{
                    icon:"home-o",
                    name:"首页"
                },
                component:Home
            },
            {
                path:"/order",
                meta:{
                    icon:"orders-o",
                    name:"订单"
                },
                component:Order
            },
            {
                path:"/user",
                meta:{
                    icon:"user-o",
                    name:"我的"
                },
                component:User
            }
        ]
    },
    // 注册
    {
        path:"/setin",
        name:"setin",
        component:Setin
    },
    // 登录
    {
        path:"/login",
        name:"login",
        component:Login
    },
    // 创建订单
    {
        path:"/createOrder",
        name:"createOrder",
        component:createOrder
    },
    // 订单详情
    {
        path:"/detail",
        name:"detail",
        component:detail
    },
]

export default createRouter({
    history:createWebHashHistory(),
    routes
})